{extend name="public/base" /}

{block name="title"}反馈内容{/block}

{block name="body"}

	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form" action="">
				<div class="layui-row layui-col-space15 ">
					<div class="layui-col-md2">
						<label class="layui-form-label">发帖人</label>
						<div class="layui-input-block">
							<input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-col-md2">
						<label class="layui-form-label">状态</label>
						<div class="layui-input-block">
							<select name="sec">
								<option value="">选择状态</option>
								<option value="0">待处理</option>
								<option value="1">已处理</option>
								<option value="2">已驳回</option>
							</select>
						</div>
					</div>
					<div class="layui-col-md2">
						<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="forum-query">
							<i class="layui-icon layui-icon-search"></i>
							查询
						</button>
						<button type="reset" class="pear-btn pear-btn-md">
							<i class="layui-icon layui-icon-refresh"></i>
							重置
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-body">
		<table id="table" lay-filter="table" ></table>
		</div>
	</div>




	<script type="text/html" id="table-bar">
		<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="reply"><i class="layui-icon layui-icon-reply-fill"></i></button>
	</script>

	{__block__}
	
	<script>
		const LIST = "{:url('content.feedback/list')}";

		layui.use(['toast','common'], function(){
			var $ = layui.jquery;
			var form = layui.form;
			var table = layui.table;

			var toast = layui.toast;
			var common = layui.common;

			table.render({
				elem: '#table',
				url: LIST,
				page: true,
				cols: [
					[
	
					{field: 'id', width: 80, title: 'ID', sort: true}
					,{field: 'name', title: '反馈人', width: 100}
					,{field: 'title', title: '问题', minWidth: 200}
					,{field: 'content', title: '内容', minWidth: 200}
					,{field: 'status',title: '状态',width: 100}
					,{field: 'create_time',title: '时间', width: 100}
					,{title: '操作', width: 110, align: 'center', toolbar: '#table-bar'}
					]
				],
				height: function(){
					var otherHeight = $('.layui-card-body:first').outerHeight(); // 自定义其他区域的高度
					return $(window).height() - otherHeight - 70; // 返回 number 类型
				},
				skin: 'line',
				lineStyle: 'height: 120px;',
				toolbar: '#forum-toolbar',
				defaultToolbar: [{
					title: '刷新',
					layEvent: 'refresh',
					icon: 'layui-icon-refresh',
				}, 'filter', 'print', 'exports'],
				limit: 30,
				limits: [30,100,200,500,1000],
				loading: true // 显示默认加载条
			});

		
		table.on('tool(table)', function(obj) {
			if (obj.event === 'remove') {
				window.remove(obj);
			} else if (obj.event === 'reply') {
				window.reply(obj);
			}
		});



		form.on('submit(forum-query)', function(data) {
			table.reloadData('table', {
				where: data.field,
				page: { // 支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
					layout: ['limit', 'count', 'prev', 'page', 'next'], //自定义分页布局
					curr: 1, //设定初始在第 5 页
					groups: 1, //只显示 1 个连续页码
					first: false, //不显示首页
					last: false //不显示尾页
				},
				scrollPos: true,
			})
			return false;
		});

		// 添加
		window.reply = function(obj) {
			console.log(obj)
			layer.open({
				type: 2,
				title: obj.data.name + '反馈',
				shade: 0.1,
				area: ['100%', '100%'],
				content: "{:url('content.feedback/reply')}?id=" + obj.data.id
			});
		}

	
		// 刷新
		window.refresh = function(param) {
			table.reload('table');
		}

	});
	</script>
{/block}
